//
// cocos2d Hello World example
// http://www.cocos2d-iphone.org
//

// Import the interfaces
#import "MainMenuScene.h"
#import "GameScene.h"

// HelloWorld implementation
@implementation MainMenu


+(id) scene
{
	// 'scene' is an autorelease object.
	CCScene *scene = [CCScene node];
	
	// 'layer' is an autorelease object.
	MainMenu *layer = [MainMenu node];
	
	// add layer as a child to scene
	[scene addChild: layer];
	
	// return the scene
	return scene;
}

// on "init" you need to initialize your instance
-(id) init
{
	// always call "super" init
	// Apple recommends to re-assign "self" with the "super" return value
	if( (self=[super init] )) {
		[CCMenuItemFont setFontSize:30];
		[CCMenuItemFont setFontName: @"Courier New"];
		
		//CCMenuItemFont *hulao = [CCMenuItemFont itemFromString: @"虎牢关" target: self selector:@selector(hulaoguan:)];
		//CCMenuItemFont *bowang = [CCMenuItemFont itemFromString: @"长坂坡" target: self selector:@selector(bowangpo:)]; 
		//CCMenuItemFont *dingjun = [CCMenuItemFont itemFromString: @"定军山" target:self selector:@selector(dingjunshan:)];
		//CCMenuItemFont *nanzhong = [CCMenuItemFont itemFromString: @"南中平定" target:self selector:@selector(nanzhong:)];
		CCSprite * normalSprite = [CCSprite spriteWithFile:@"taup_da.png"];
		CCMenuItemSprite * TestSpr = [CCMenuItemSprite itemFromNormalSprite:normalSprite selectedSprite:normalSprite target:self selector:@selector(nanzhong:)];
		CCSprite * spriteTwo = [CCSprite spriteWithFile:@"touqu2.png"];
		[normalSprite addChild:spriteTwo z:10];
		//[self addChild:normalSprite z:10];
		normalSprite.position = ccp(100,100);
		spriteTwo.position = ccp(50,50);
		CCMenu *menu = [CCMenu menuWithItems:TestSpr, nil];
		[menu alignItemsVertically];
		[self addChild:menu];
		
		[[Parameter sharedParameter] LoadFile];
		
		
	}
	return self;
}


-(void) bowangpo:(id)sender
{
	[[Parameter sharedParameter] setStage:2];
	
	[[CCDirector sharedDirector] replaceScene:[Game scene]];
	printf("bowang\n");
	
}

-(void) hulaoguan:(id)sender
{
	[[Parameter sharedParameter] setStage:1];
	
	[[CCDirector sharedDirector] replaceScene:[Game scene]];
	printf("hulao\n");
}

-(void) dingjunshan:(id)sender
{
	[[Parameter sharedParameter] setStage:3];
	
	[[CCDirector sharedDirector] replaceScene:[Game scene]];
	printf("dingjun\n");
}

-(void) nanzhong:(id)sender
{
	[[Parameter sharedParameter] setStage:4];
	
	[[CCDirector sharedDirector] replaceScene:[Game scene]];
	printf("nanzhong\n");
}


// on "dealloc" you need to release all your retained objects
- (void) dealloc
{
	// in case you have something to dealloc, do it in this method
	// in this particular example nothing needs to be released.
	// cocos2d will automatically release all the children (Label)
	
	// don't forget to call "super dealloc"
	[super dealloc];
}
@end
